package com.csx.governance.traffic.core.support;

import com.csx.governance.traffic.core.RequestAfterCompletionCleaner;
import com.csx.governance.traffic.core.TransportableAttributes;
import com.csx.governance.traffic.core.context.TrafficContextHolder;
import com.csx.governance.traffic.core.context.TrafficInternalContexts;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * <p>请求结束后的资源清理器</p>
 * <p>该请求器主要负责清理 请求的上下文信息</p>
 * @author cuisongxu
 * @date 2023/3/18 13:20
 */
public class DefaultRequestAfterCompletionCleaner implements RequestAfterCompletionCleaner {

    private final Logger logger = LoggerFactory.getLogger(DefaultRequestAfterCompletionCleaner.class);

    @Override
    public void clean() {
        TrafficContextHolder.clearContext();
        TrafficInternalContexts.clear();
        logger.debug("current context will had been cleaned up [ {} ]", TransportableAttributes.getAttributes());
    }
}
